/**
 * 相关配置类
 */


import {visitPath} from "@/Interface/FileApi";

/**
 * 字典转换
 */
export const dictStatus = (list,value)=>{
    let name = ''
    list.forEach(item=>{
        if (item.value.toString()===value.toString()){
            name = item.label;
        }
    })
    return name;
}

/**
 * 判空
 */

export function isEmpty(value) {
    return value === null || value === undefined || value === '' || value==="" || value.length<=0 || value==="null" || value===0;
}

/**
 *账号登陆
 */
export function backLogin(value) {
    let user = JSON.parse(localStorage.getItem('xm-user'));
    if (user.role==value){}else if(user.role=="STAFF"){} else {
        localStorage.removeItem("xm-user");
        localStorage.removeItem("token");
        location.href = '/'
    }
}

/**
 * 图片预览
 */
export function imgListFun(value){
    let list = [];
    if (Array.isArray(value)){
        value.map(item=>{
            list.push(visitPath+item.img)
        })
    }
    return list;
}

/**
 * 房间设备转换
 */
export function deviceListFun(value){
    let list = [];
    if (Array.isArray(value)){
        value.map(item=>{
            list.push(item.label)
        })
    }
    return list.toString();
}

/**
 * 名称转换
 */
export function titleListFun(value){
    let list = [];
    if (Array.isArray(value)){
        value.map(item=>{
            list.push(item.title)
        })
    }

    return list.toString();
}




